<template>
    <div class="subject">
        <div class="box">

            <div class="avg"
                 v-for="(obj,i) in subjectList"
                 :key="obj.subjectId"
                 @click="goDetails(obj)">
                <!-- @click="gotoDetails(obj)">-->

                <!--课程图片-->
                <div class="img-box">
                    <img :src="obj.subPic">
                </div>

                <!--课程名称-->
                <div class="name">
                    {{obj.subName}}
                </div>

                <!--课程简介-->
                <div class="introduction">
                    {{obj.subIntroduction}}
                </div>

                <div class="other-box">
                    <div class="vip">
                        <span v-if="obj.vip==1" class="yes">会员</span>
                        <span v-if="obj.vip==0" class="no">免费</span>
                    </div>
                    <div class="view">

                    </div>
                    <div class="score">
                        <el-rate disabled
                                 allow-half
                                 v-model="obj.subScore"
                                 :low-threshold=1.5
                                 :high-threshold=3
                                 style="width:120px"
                                 :colors="['#99A9BF', '#F7BA2A', '#FF9900']">
                        </el-rate>
                    </div>
                </div>
            </div>

        </div>
    </div>
</template>

<script>
    export default {
        name: "",
        components: {},
        data() {
            return {
                subjectList: [],
                subject: {
                    //主键Id
                    subjectId: "",
                    //科目名称
                    subName: "",
                    //课程图片
                    subPic: "",
                    //课程社区url
                    subCommunityUrl: "",
                    //课程教师
                    subTeacher: "",
                    //qq群
                    qqGroup: "",
                    //课程简介
                    subIntroduction: "",
                    //课时总数
                    subTotal: "",
                    //课程评分，0-5，默认5分
                    subScore: "",
                    //是否vip课程 默认0,非vip课程
                    vip: "",
                    //显示排序
                    showOrder: "",
                    //状态  1在用  0失效
                    status: "",
                    //创建人id
                    createUser: "",
                    //创建时间
                    createTime: "",
                }
            }
        },
        methods: {
            //查询列表
            selectSubjectList: function () {
                this.axios.get(`/course/web-subject/subjectList`)
                    .then((data) => {
                        if (data.code == 200) {
                            this.subjectList = data.data
                        }
                    })
            },
            //去到具体课程
            goDetails: function (obj) {
                //跳转
                let {href} = this.$router.resolve({
                    name: "CourseList",
                    query: {
                        sid: obj.subjectId
                    }
                });
                window.open(href, '_blank');
            }
        },
        mounted() {
            this.selectSubjectList()
        }
    }
</script>

<style scoped>
    .subject {
        width: 1200px;
        min-height: calc(100vh - 70px);
        margin: 0 auto;
        position: relative;
    }

    .subject .box {
        overflow: hidden;
    }


    /*5等分*/
    .subject .box .avg {
        margin: 40px 0px 0px 30px;
        cursor: pointer;
        float: left;
        /*width: calc(20% - 30px);*/
        width: 210px;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: space-between;
        align-items: flex-start;
        overflow: hidden;
    }

    .subject .box .avg :nth-child(5n+1) {
        margin-left: 0px;
    }

    /*img盒子*/
    .subject .box .avg .img-box {
        width: 216px;
        height: 120px;
        border-radius: 6px;
    }

    /*课程图片*/
    .subject .box .avg img {
        display: inline-block;
        width: 208px;
        height: 112px;
        margin-top: 4px;
        margin-left: 4px;
        border-radius: 6px;
    }

    .subject .box .avg img:hover {
        display: inline-block;
        width: 216px;
        height: 120px;
        margin-top: 0px;
        margin-left: 0px;
        border-radius: 6px;
    }

    /*课程名称*/
    .subject .box .avg .name {
        width: 100%;
        height: 32px;
        font-size: 16px;
        line-height: 16px;
        color: #07111B;
        font-family: 微软雅黑;
        font-weight: bold;
    }

    /*课程名称*/
    .subject .box .avg .name:hover {
        width: 100%;
        height: 32px;
        font-size: 16px;
        line-height: 16px;
        color: #F20A0A;
        font-family: 微软雅黑;
        font-weight: bold;
    }

    /*简介*/
    .subject .box .avg .introduction {
        width: 100%;
        height: 32px;
        margin-top: 5px;
        font-size: 14px;
        color: rgba(135, 135, 135, 1);;
        line-height: 16px;

        /*溢出省略...*/
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /*其他*/
    .subject .box .avg .other-box {
        width: 100%;
        overflow: hidden;
    }

    /*vip*/
    .subject .box .avg .other-box .vip {
        float: left;
    }

    .subject .box .avg .other-box .vip .yes {
        font-size: 14px;
        color: #ffac41;
        font-weight: bolder;
    }

    .subject .box .avg .other-box .vip .no {
        font-size: 14px;
        color: #F20A0A;
        font-weight: bolder;
    }

    .subject .box .avg .other-box .view {
        float: left;
    }

    .subject .box .avg .other-box .score {
        float: right;
    }
</style>